package com.kbbywyclient.presenter;

import android.content.Context;

import com.kbbywyclient.data.model.ClerkDetailsModel;
import com.kbbywyclient.presenter.base.BasePresenter;
import com.kbbywyclient.service.ApiService;
import com.kbbywyclient.service.ApiServiceHelper;
import com.kbbywyclient.ui.contarct.ClerkDetailsContract;
import com.kbbywyclient.util.RsaJsonUtil;

import javax.inject.Inject;

import rx.Subscriber;

/**
 * Created by Jiangzx on 2017/11/2 11:42.
 */

public class ClerkDetailsPresenter extends BasePresenter implements ClerkDetailsContract.Presenter {
    @Inject
    Context context;
    @Inject
    ApiService apiService;
    @Inject
    RsaJsonUtil jsonUtil;

    private ClerkDetailsContract.View view;


    @Inject
    public ClerkDetailsPresenter(ClerkDetailsContract.View view){
        this.view=view;
    }

    @Override
    public void loadClerkDetails(int salesId, int clerkId) {
        jsonUtil.put("member_id",salesId);
        jsonUtil.put("sales_id",clerkId);
        ApiServiceHelper.
                appointThreadNormal(apiService.getClerkDetails(jsonUtil.getRsaParams())).
                subscribe(new Subscriber<ClerkDetailsModel>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(ClerkDetailsModel clerkDetailsModel) {
                        view.onClerkDetailsSuccess(clerkDetailsModel.getData());
                    }
                });
    }
}
